package controller;

import beans.HttpResultList;
import dao.*;
import net.sf.json.JSONObject;
import portal.controller.BaseServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;

import java.io.IOException;
import java.util.List;

public class HomePageInfo extends BaseServlet {
	@Autowired
	AlgorithmDao algorithmDao;
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        
        int algorithmNum = algorithmDao.getAlgorithmNum();
        int modelNum = new ModelDao().modelNum();
        int taskNum = new TaskDao().getTaskPageNum();
        List<Object> historyTaskInfo = new HistoryTaskDao().getHistory_Tasks(0,0);
        JSONObject result = new JSONObject();
        result.put("historyTask",historyTaskInfo);
        result.put("algorithmNum",algorithmNum);
        result.put("modelNum",modelNum);
        result.put("taskNum",taskNum);
        response.getWriter().write(result.toString());
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
